using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using SJVars;
using Spacejock;
using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Windows.Forms;
using yW5Lib;

namespace yWriter6
{
	[DesignerGenerated]
	internal class frmEditChapter : Form
	{
		public delegate void NextChapterEventHandler(int CurrentID);

		public delegate void PrevChapterEventHandler(int CurrentID);

		private IContainer components;

		public ToolTip ToolTip1;

		[CompilerGenerated]
		[AccessedThroughProperty("txtSceneSummary")]
		private TextBox _txtSceneSummary;

		[CompilerGenerated]
		[AccessedThroughProperty("txtDesc")]
		private RichTextBox _txtDesc;

		[CompilerGenerated]
		[AccessedThroughProperty("txtTitle")]
		private TextBox _txtTitle;

		[CompilerGenerated]
		[AccessedThroughProperty("Label2")]
		private Label _Label2;

		[CompilerGenerated]
		[AccessedThroughProperty("Label1")]
		private Label _Label1;

		[CompilerGenerated]
		[AccessedThroughProperty("cmdOK")]
		private Button _cmdOK;

		[CompilerGenerated]
		[AccessedThroughProperty("cmdExit")]
		private Button _cmdExit;

		[CompilerGenerated]
		[AccessedThroughProperty("Image1")]
		private PictureBox _Image1;

		[CompilerGenerated]
		[AccessedThroughProperty("TabControl1")]
		private TabControl _TabControl1;

		[CompilerGenerated]
		[AccessedThroughProperty("TabDetails")]
		private TabPage _TabDetails;

		[CompilerGenerated]
		[AccessedThroughProperty("TableLayoutPanel1")]
		private TableLayoutPanel _TableLayoutPanel1;

		[CompilerGenerated]
		[AccessedThroughProperty("TabSummary")]
		private TabPage _TabSummary;

		[CompilerGenerated]
		[AccessedThroughProperty("chkSectionStart")]
		private CheckBox _chkSectionStart;

		[CompilerGenerated]
		[AccessedThroughProperty("TabBooks")]
		private TabPage _TabBooks;

		[CompilerGenerated]
		[AccessedThroughProperty("Label5")]
		private Label _Label5;

		[CompilerGenerated]
		[AccessedThroughProperty("Label4")]
		private Label _Label4;

		[CompilerGenerated]
		[AccessedThroughProperty("Label3")]
		private Label _Label3;

		[CompilerGenerated]
		[AccessedThroughProperty("cmbParts")]
		private ComboBox _cmbParts;

		[CompilerGenerated]
		[AccessedThroughProperty("cmbBooks")]
		private ComboBox _cmbBooks;

		[CompilerGenerated]
		[AccessedThroughProperty("cmdSetupBooks")]
		private Button _cmdSetupBooks;

		[CompilerGenerated]
		[AccessedThroughProperty("cmdPrevChapter")]
		private Button _cmdPrevChapter;

		[CompilerGenerated]
		[AccessedThroughProperty("cmdNextChapter")]
		private Button _cmdNextChapter;

		public string NewTitle;

		public string NewDesc;

		public bool NewSectionStart;

		[CompilerGenerated]
		private NextChapterEventHandler NextChapterEvent;

		[CompilerGenerated]
		private PrevChapterEventHandler PrevChapterEvent;

		private clsProject cProject;

		private clsChapter CurrentChapter;

		private bool SuppressComboChange;

		public bool Cancelled;

		[field: AccessedThroughProperty("txtSceneSummary")]
		public virtual TextBox txtSceneSummary
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[field: AccessedThroughProperty("txtDesc")]
		public virtual RichTextBox txtDesc
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		public virtual TextBox txtTitle
		{
			[CompilerGenerated]
			get
			{
				return _txtTitle;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = txtTitle_Enter;
				TextBox txtTitle = _txtTitle;
				if (txtTitle != null)
				{
					txtTitle.Enter -= value2;
				}
				_txtTitle = value;
				txtTitle = _txtTitle;
				if (txtTitle != null)
				{
					txtTitle.Enter += value2;
				}
			}
		}

		[field: AccessedThroughProperty("Label2")]
		public virtual Label Label2
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[field: AccessedThroughProperty("Label1")]
		public virtual Label Label1
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		public virtual Button cmdOK
		{
			[CompilerGenerated]
			get
			{
				return _cmdOK;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = cmdOK_Click;
				Button cmdOK = _cmdOK;
				if (cmdOK != null)
				{
					cmdOK.Click -= value2;
				}
				_cmdOK = value;
				cmdOK = _cmdOK;
				if (cmdOK != null)
				{
					cmdOK.Click += value2;
				}
			}
		}

		public virtual Button cmdExit
		{
			[CompilerGenerated]
			get
			{
				return _cmdExit;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = cmdExit_Click;
				Button cmdExit = _cmdExit;
				if (cmdExit != null)
				{
					cmdExit.Click -= value2;
				}
				_cmdExit = value;
				cmdExit = _cmdExit;
				if (cmdExit != null)
				{
					cmdExit.Click += value2;
				}
			}
		}

		[field: AccessedThroughProperty("Image1")]
		public virtual PictureBox Image1
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[field: AccessedThroughProperty("TabControl1")]
		internal virtual TabControl TabControl1
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[field: AccessedThroughProperty("TabDetails")]
		internal virtual TabPage TabDetails
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[field: AccessedThroughProperty("TableLayoutPanel1")]
		internal virtual TableLayoutPanel TableLayoutPanel1
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[field: AccessedThroughProperty("TabSummary")]
		internal virtual TabPage TabSummary
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[field: AccessedThroughProperty("chkSectionStart")]
		internal virtual CheckBox chkSectionStart
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[field: AccessedThroughProperty("TabBooks")]
		internal virtual TabPage TabBooks
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[field: AccessedThroughProperty("Label5")]
		internal virtual Label Label5
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[field: AccessedThroughProperty("Label4")]
		internal virtual Label Label4
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[field: AccessedThroughProperty("Label3")]
		internal virtual Label Label3
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[field: AccessedThroughProperty("cmbParts")]
		internal virtual ComboBox cmbParts
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		internal virtual ComboBox cmbBooks
		{
			[CompilerGenerated]
			get
			{
				return _cmbBooks;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = cmbBooks_SelectedIndexChanged;
				ComboBox cmbBooks = _cmbBooks;
				if (cmbBooks != null)
				{
					cmbBooks.SelectedIndexChanged -= value2;
				}
				_cmbBooks = value;
				cmbBooks = _cmbBooks;
				if (cmbBooks != null)
				{
					cmbBooks.SelectedIndexChanged += value2;
				}
			}
		}

		internal virtual Button cmdSetupBooks
		{
			[CompilerGenerated]
			get
			{
				return _cmdSetupBooks;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = cmdSetupBooks_Click;
				Button cmdSetupBooks = _cmdSetupBooks;
				if (cmdSetupBooks != null)
				{
					cmdSetupBooks.Click -= value2;
				}
				_cmdSetupBooks = value;
				cmdSetupBooks = _cmdSetupBooks;
				if (cmdSetupBooks != null)
				{
					cmdSetupBooks.Click += value2;
				}
			}
		}

		internal virtual Button cmdPrevChapter
		{
			[CompilerGenerated]
			get
			{
				return _cmdPrevChapter;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = cmdPrevChapter_Click;
				Button cmdPrevChapter = _cmdPrevChapter;
				if (cmdPrevChapter != null)
				{
					cmdPrevChapter.Click -= value2;
				}
				_cmdPrevChapter = value;
				cmdPrevChapter = _cmdPrevChapter;
				if (cmdPrevChapter != null)
				{
					cmdPrevChapter.Click += value2;
				}
			}
		}

		internal virtual Button cmdNextChapter
		{
			[CompilerGenerated]
			get
			{
				return _cmdNextChapter;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = cmdNextChapter_Click;
				Button cmdNextChapter = _cmdNextChapter;
				if (cmdNextChapter != null)
				{
					cmdNextChapter.Click -= value2;
				}
				_cmdNextChapter = value;
				cmdNextChapter = _cmdNextChapter;
				if (cmdNextChapter != null)
				{
					cmdNextChapter.Click += value2;
				}
			}
		}

		public event NextChapterEventHandler NextChapter
		{
			[CompilerGenerated]
			add
			{
				NextChapterEventHandler nextChapterEventHandler = NextChapterEvent;
				NextChapterEventHandler nextChapterEventHandler2;
				do
				{
					nextChapterEventHandler2 = nextChapterEventHandler;
					NextChapterEventHandler value2 = (NextChapterEventHandler)Delegate.Combine(nextChapterEventHandler2, value);
					nextChapterEventHandler = Interlocked.CompareExchange(ref NextChapterEvent, value2, nextChapterEventHandler2);
				}
				while ((object)nextChapterEventHandler != nextChapterEventHandler2);
			}
			[CompilerGenerated]
			remove
			{
				NextChapterEventHandler nextChapterEventHandler = NextChapterEvent;
				NextChapterEventHandler nextChapterEventHandler2;
				do
				{
					nextChapterEventHandler2 = nextChapterEventHandler;
					NextChapterEventHandler value2 = (NextChapterEventHandler)Delegate.Remove(nextChapterEventHandler2, value);
					nextChapterEventHandler = Interlocked.CompareExchange(ref NextChapterEvent, value2, nextChapterEventHandler2);
				}
				while ((object)nextChapterEventHandler != nextChapterEventHandler2);
			}
		}

		public event PrevChapterEventHandler PrevChapter
		{
			[CompilerGenerated]
			add
			{
				PrevChapterEventHandler prevChapterEventHandler = PrevChapterEvent;
				PrevChapterEventHandler prevChapterEventHandler2;
				do
				{
					prevChapterEventHandler2 = prevChapterEventHandler;
					PrevChapterEventHandler value2 = (PrevChapterEventHandler)Delegate.Combine(prevChapterEventHandler2, value);
					prevChapterEventHandler = Interlocked.CompareExchange(ref PrevChapterEvent, value2, prevChapterEventHandler2);
				}
				while ((object)prevChapterEventHandler != prevChapterEventHandler2);
			}
			[CompilerGenerated]
			remove
			{
				PrevChapterEventHandler prevChapterEventHandler = PrevChapterEvent;
				PrevChapterEventHandler prevChapterEventHandler2;
				do
				{
					prevChapterEventHandler2 = prevChapterEventHandler;
					PrevChapterEventHandler value2 = (PrevChapterEventHandler)Delegate.Remove(prevChapterEventHandler2, value);
					prevChapterEventHandler = Interlocked.CompareExchange(ref PrevChapterEvent, value2, prevChapterEventHandler2);
				}
				while ((object)prevChapterEventHandler != prevChapterEventHandler2);
			}
		}

		[DebuggerNonUserCode]
		protected override void Dispose(bool Disposing)
		{
			if (Disposing && components != null)
			{
				components.Dispose();
			}
			base.Dispose(Disposing);
		}

		[System.Diagnostics.DebuggerStepThrough]
		private void InitializeComponent()
		{
			components = new System.ComponentModel.Container();
			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(yWriter6.frmEditChapter));
			ToolTip1 = new System.Windows.Forms.ToolTip(components);
			txtSceneSummary = new System.Windows.Forms.TextBox();
			txtDesc = new System.Windows.Forms.RichTextBox();
			cmdPrevChapter = new System.Windows.Forms.Button();
			cmdNextChapter = new System.Windows.Forms.Button();
			txtTitle = new System.Windows.Forms.TextBox();
			Label2 = new System.Windows.Forms.Label();
			Label1 = new System.Windows.Forms.Label();
			cmdOK = new System.Windows.Forms.Button();
			cmdExit = new System.Windows.Forms.Button();
			Image1 = new System.Windows.Forms.PictureBox();
			TabControl1 = new System.Windows.Forms.TabControl();
			TabDetails = new System.Windows.Forms.TabPage();
			TableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
			chkSectionStart = new System.Windows.Forms.CheckBox();
			TabBooks = new System.Windows.Forms.TabPage();
			cmdSetupBooks = new System.Windows.Forms.Button();
			Label5 = new System.Windows.Forms.Label();
			Label4 = new System.Windows.Forms.Label();
			Label3 = new System.Windows.Forms.Label();
			cmbParts = new System.Windows.Forms.ComboBox();
			cmbBooks = new System.Windows.Forms.ComboBox();
			TabSummary = new System.Windows.Forms.TabPage();
			((System.ComponentModel.ISupportInitialize)Image1).BeginInit();
			TabControl1.SuspendLayout();
			TabDetails.SuspendLayout();
			TableLayoutPanel1.SuspendLayout();
			TabBooks.SuspendLayout();
			TabSummary.SuspendLayout();
			SuspendLayout();
			txtSceneSummary.AcceptsReturn = true;
			txtSceneSummary.BackColor = System.Drawing.SystemColors.Window;
			txtSceneSummary.Cursor = System.Windows.Forms.Cursors.Default;
			txtSceneSummary.Dock = System.Windows.Forms.DockStyle.Fill;
			txtSceneSummary.Font = new System.Drawing.Font("Segoe UI", 10f);
			txtSceneSummary.ForeColor = System.Drawing.SystemColors.WindowText;
			txtSceneSummary.Location = new System.Drawing.Point(3, 4);
			txtSceneSummary.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			txtSceneSummary.MaxLength = 0;
			txtSceneSummary.Multiline = true;
			txtSceneSummary.Name = "txtSceneSummary";
			txtSceneSummary.ReadOnly = true;
			txtSceneSummary.RightToLeft = System.Windows.Forms.RightToLeft.No;
			txtSceneSummary.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
			txtSceneSummary.Size = new System.Drawing.Size(569, 290);
			txtSceneSummary.TabIndex = 11;
			ToolTip1.SetToolTip(txtSceneSummary, "Automatically generated from scene descriptions.");
			txtDesc.AcceptsTab = true;
			txtDesc.BackColor = System.Drawing.SystemColors.Window;
			txtDesc.Cursor = System.Windows.Forms.Cursors.IBeam;
			txtDesc.Dock = System.Windows.Forms.DockStyle.Fill;
			txtDesc.Font = new System.Drawing.Font("Segoe UI", 10f);
			txtDesc.ForeColor = System.Drawing.SystemColors.WindowText;
			txtDesc.Location = new System.Drawing.Point(90, 37);
			txtDesc.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			txtDesc.MaxLength = 0;
			txtDesc.Name = "txtDesc";
			txtDesc.RightToLeft = System.Windows.Forms.RightToLeft.No;
			txtDesc.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical;
			txtDesc.Size = new System.Drawing.Size(476, 218);
			txtDesc.TabIndex = 2;
			txtDesc.Text = "";
			ToolTip1.SetToolTip(txtDesc, "This box is where you enter a short description of the current chapter.\r\nTo enter scene text, return to the main screen, click 'Scene' then 'Add Scene'");
			cmdPrevChapter.Font = new System.Drawing.Font("Segoe UI", 10f);
			cmdPrevChapter.Location = new System.Drawing.Point(8, 83);
			cmdPrevChapter.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			cmdPrevChapter.Name = "cmdPrevChapter";
			cmdPrevChapter.Size = new System.Drawing.Size(37, 44);
			cmdPrevChapter.TabIndex = 6;
			cmdPrevChapter.Text = "<";
			ToolTip1.SetToolTip(cmdPrevChapter, "Previous Chapter");
			cmdPrevChapter.UseVisualStyleBackColor = true;
			cmdNextChapter.Font = new System.Drawing.Font("Segoe UI", 10f);
			cmdNextChapter.Location = new System.Drawing.Point(8, 134);
			cmdNextChapter.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			cmdNextChapter.Name = "cmdNextChapter";
			cmdNextChapter.Size = new System.Drawing.Size(37, 44);
			cmdNextChapter.TabIndex = 6;
			cmdNextChapter.Text = ">";
			ToolTip1.SetToolTip(cmdNextChapter, "Next Chapter");
			cmdNextChapter.UseVisualStyleBackColor = true;
			txtTitle.AcceptsReturn = true;
			txtTitle.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right);
			txtTitle.BackColor = System.Drawing.SystemColors.Window;
			txtTitle.Cursor = System.Windows.Forms.Cursors.IBeam;
			txtTitle.Font = new System.Drawing.Font("Segoe UI", 10f);
			txtTitle.ForeColor = System.Drawing.SystemColors.WindowText;
			txtTitle.Location = new System.Drawing.Point(90, 4);
			txtTitle.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			txtTitle.MaxLength = 0;
			txtTitle.Name = "txtTitle";
			txtTitle.RightToLeft = System.Windows.Forms.RightToLeft.No;
			txtTitle.Size = new System.Drawing.Size(476, 25);
			txtTitle.TabIndex = 1;
			Label2.AutoSize = true;
			Label2.BackColor = System.Drawing.Color.Transparent;
			Label2.Cursor = System.Windows.Forms.Cursors.Default;
			Label2.Dock = System.Windows.Forms.DockStyle.Fill;
			Label2.Font = new System.Drawing.Font("Segoe UI", 10f);
			Label2.ForeColor = System.Drawing.SystemColors.ControlText;
			Label2.Location = new System.Drawing.Point(3, 33);
			Label2.Name = "Label2";
			Label2.Padding = new System.Windows.Forms.Padding(0, 6, 0, 0);
			Label2.RightToLeft = System.Windows.Forms.RightToLeft.No;
			Label2.Size = new System.Drawing.Size(81, 226);
			Label2.TabIndex = 6;
			Label2.Text = "Description:";
			Label2.TextAlign = System.Drawing.ContentAlignment.TopRight;
			Label1.AutoSize = true;
			Label1.BackColor = System.Drawing.Color.Transparent;
			Label1.Cursor = System.Windows.Forms.Cursors.Default;
			Label1.Dock = System.Windows.Forms.DockStyle.Fill;
			Label1.Font = new System.Drawing.Font("Segoe UI", 10f);
			Label1.ForeColor = System.Drawing.SystemColors.ControlText;
			Label1.Location = new System.Drawing.Point(3, 0);
			Label1.Name = "Label1";
			Label1.Padding = new System.Windows.Forms.Padding(0, 6, 0, 0);
			Label1.RightToLeft = System.Windows.Forms.RightToLeft.No;
			Label1.Size = new System.Drawing.Size(81, 33);
			Label1.TabIndex = 5;
			Label1.Text = "Title:";
			Label1.TextAlign = System.Drawing.ContentAlignment.TopRight;
			cmdOK.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			cmdOK.BackColor = System.Drawing.SystemColors.Control;
			cmdOK.Cursor = System.Windows.Forms.Cursors.Default;
			cmdOK.Font = new System.Drawing.Font("Segoe UI", 10f);
			cmdOK.ForeColor = System.Drawing.SystemColors.ControlText;
			cmdOK.Location = new System.Drawing.Point(540, 349);
			cmdOK.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			cmdOK.Name = "cmdOK";
			cmdOK.RightToLeft = System.Windows.Forms.RightToLeft.No;
			cmdOK.Size = new System.Drawing.Size(91, 51);
			cmdOK.TabIndex = 16;
			cmdOK.Text = "OK";
			cmdOK.UseVisualStyleBackColor = true;
			cmdExit.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			cmdExit.BackColor = System.Drawing.SystemColors.Control;
			cmdExit.Cursor = System.Windows.Forms.Cursors.Default;
			cmdExit.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			cmdExit.Font = new System.Drawing.Font("Segoe UI", 10f);
			cmdExit.ForeColor = System.Drawing.SystemColors.ControlText;
			cmdExit.Location = new System.Drawing.Point(52, 349);
			cmdExit.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			cmdExit.Name = "cmdExit";
			cmdExit.RightToLeft = System.Windows.Forms.RightToLeft.No;
			cmdExit.Size = new System.Drawing.Size(92, 51);
			cmdExit.TabIndex = 15;
			cmdExit.Text = "Cancel";
			cmdExit.UseVisualStyleBackColor = true;
			Image1.Cursor = System.Windows.Forms.Cursors.Default;
			Image1.Image = (System.Drawing.Image)resources.GetObject("Image1.Image");
			Image1.Location = new System.Drawing.Point(8, 13);
			Image1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			Image1.Name = "Image1";
			Image1.Size = new System.Drawing.Size(32, 32);
			Image1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
			Image1.TabIndex = 11;
			Image1.TabStop = false;
			TabControl1.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right);
			TabControl1.Controls.Add(TabDetails);
			TabControl1.Controls.Add(TabBooks);
			TabControl1.Controls.Add(TabSummary);
			TabControl1.Location = new System.Drawing.Point(52, 13);
			TabControl1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			TabControl1.Name = "TabControl1";
			TabControl1.SelectedIndex = 0;
			TabControl1.Size = new System.Drawing.Size(583, 328);
			TabControl1.TabIndex = 13;
			TabDetails.Controls.Add(TableLayoutPanel1);
			TabDetails.Location = new System.Drawing.Point(4, 26);
			TabDetails.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			TabDetails.Name = "TabDetails";
			TabDetails.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
			TabDetails.Size = new System.Drawing.Size(575, 298);
			TabDetails.TabIndex = 0;
			TabDetails.Text = "Chapter Details";
			TabDetails.UseVisualStyleBackColor = true;
			TableLayoutPanel1.ColumnCount = 3;
			TableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
			TableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100f));
			TableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
			TableLayoutPanel1.Controls.Add(Label1, 0, 0);
			TableLayoutPanel1.Controls.Add(Label2, 0, 1);
			TableLayoutPanel1.Controls.Add(txtTitle, 1, 0);
			TableLayoutPanel1.Controls.Add(txtDesc, 1, 1);
			TableLayoutPanel1.Controls.Add(chkSectionStart, 1, 2);
			TableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
			TableLayoutPanel1.Location = new System.Drawing.Point(3, 4);
			TableLayoutPanel1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			TableLayoutPanel1.Name = "TableLayoutPanel1";
			TableLayoutPanel1.RowCount = 3;
			TableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
			TableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100f));
			TableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
			TableLayoutPanel1.Size = new System.Drawing.Size(569, 290);
			TableLayoutPanel1.TabIndex = 5;
			chkSectionStart.AutoSize = true;
			chkSectionStart.Dock = System.Windows.Forms.DockStyle.Fill;
			chkSectionStart.Font = new System.Drawing.Font("Segoe UI", 10f);
			chkSectionStart.Location = new System.Drawing.Point(90, 263);
			chkSectionStart.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			chkSectionStart.Name = "chkSectionStart";
			chkSectionStart.Size = new System.Drawing.Size(476, 23);
			chkSectionStart.TabIndex = 3;
			chkSectionStart.Text = "This chapter begins a new section";
			chkSectionStart.UseVisualStyleBackColor = true;
			TabBooks.Controls.Add(cmdSetupBooks);
			TabBooks.Controls.Add(Label5);
			TabBooks.Controls.Add(Label4);
			TabBooks.Controls.Add(Label3);
			TabBooks.Controls.Add(cmbParts);
			TabBooks.Controls.Add(cmbBooks);
			TabBooks.Location = new System.Drawing.Point(4, 26);
			TabBooks.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			TabBooks.Name = "TabBooks";
			TabBooks.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
			TabBooks.Size = new System.Drawing.Size(575, 298);
			TabBooks.TabIndex = 2;
			TabBooks.Text = "Book and Part Number";
			TabBooks.UseVisualStyleBackColor = true;
			cmdSetupBooks.Location = new System.Drawing.Point(23, 168);
			cmdSetupBooks.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			cmdSetupBooks.Name = "cmdSetupBooks";
			cmdSetupBooks.Size = new System.Drawing.Size(87, 43);
			cmdSetupBooks.TabIndex = 7;
			cmdSetupBooks.Text = "Setup";
			cmdSetupBooks.UseVisualStyleBackColor = true;
			Label5.Anchor = System.Windows.Forms.AnchorStyles.None;
			Label5.Location = new System.Drawing.Point(118, 167);
			Label5.Name = "Label5";
			Label5.Size = new System.Drawing.Size(430, 55);
			Label5.TabIndex = 3;
			Label5.Text = "You can specify which Book and/or Part this chapter belongs to. Click Setup to create new books and parts.";
			Label4.Anchor = System.Windows.Forms.AnchorStyles.None;
			Label4.Location = new System.Drawing.Point(114, 99);
			Label4.Name = "Label4";
			Label4.Size = new System.Drawing.Size(59, 19);
			Label4.TabIndex = 2;
			Label4.Text = "Part:";
			Label4.TextAlign = System.Drawing.ContentAlignment.TopRight;
			Label3.Anchor = System.Windows.Forms.AnchorStyles.None;
			Label3.Location = new System.Drawing.Point(114, 50);
			Label3.Name = "Label3";
			Label3.Size = new System.Drawing.Size(59, 21);
			Label3.TabIndex = 2;
			Label3.Text = "Book:";
			Label3.TextAlign = System.Drawing.ContentAlignment.TopRight;
			cmbParts.Anchor = System.Windows.Forms.AnchorStyles.None;
			cmbParts.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			cmbParts.FormattingEnabled = true;
			cmbParts.Location = new System.Drawing.Point(181, 95);
			cmbParts.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			cmbParts.MaxDropDownItems = 15;
			cmbParts.Name = "cmbParts";
			cmbParts.Size = new System.Drawing.Size(255, 25);
			cmbParts.TabIndex = 6;
			cmbBooks.Anchor = System.Windows.Forms.AnchorStyles.None;
			cmbBooks.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			cmbBooks.FormattingEnabled = true;
			cmbBooks.Location = new System.Drawing.Point(181, 46);
			cmbBooks.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			cmbBooks.MaxDropDownItems = 15;
			cmbBooks.Name = "cmbBooks";
			cmbBooks.Size = new System.Drawing.Size(255, 25);
			cmbBooks.TabIndex = 5;
			TabSummary.Controls.Add(txtSceneSummary);
			TabSummary.Location = new System.Drawing.Point(4, 26);
			TabSummary.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			TabSummary.Name = "TabSummary";
			TabSummary.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
			TabSummary.Size = new System.Drawing.Size(575, 298);
			TabSummary.TabIndex = 1;
			TabSummary.Text = "Scene Summaries (Read only)";
			TabSummary.UseVisualStyleBackColor = true;
			base.AcceptButton = cmdOK;
			base.AutoScaleDimensions = new System.Drawing.SizeF(7f, 17f);
			base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			BackColor = System.Drawing.SystemColors.Control;
			base.CancelButton = cmdExit;
			base.ClientSize = new System.Drawing.Size(651, 414);
			base.Controls.Add(cmdNextChapter);
			base.Controls.Add(cmdPrevChapter);
			base.Controls.Add(TabControl1);
			base.Controls.Add(cmdOK);
			base.Controls.Add(cmdExit);
			base.Controls.Add(Image1);
			Cursor = System.Windows.Forms.Cursors.Default;
			DoubleBuffered = true;
			Font = new System.Drawing.Font("Segoe UI", 10f);
			base.Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon");
			base.Location = new System.Drawing.Point(4, 23);
			base.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			base.MinimizeBox = false;
			MinimumSize = new System.Drawing.Size(590, 421);
			base.Name = "frmEditChapter";
			RightToLeft = System.Windows.Forms.RightToLeft.No;
			base.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			Text = "Chapter Details";
			((System.ComponentModel.ISupportInitialize)Image1).EndInit();
			TabControl1.ResumeLayout(false);
			TabDetails.ResumeLayout(false);
			TableLayoutPanel1.ResumeLayout(false);
			TableLayoutPanel1.PerformLayout();
			TabBooks.ResumeLayout(false);
			TabSummary.ResumeLayout(false);
			TabSummary.PerformLayout();
			ResumeLayout(false);
			PerformLayout();
		}

		public frmEditChapter(ref clsProject ProjectClass, int ChID)
		{
			base.Load += frmEditChapter_Load;
			base.FormClosing += frmEditChapter_FormClosing;
			InitializeComponent();
			cProject = ProjectClass;
			if (cProject.Chapters.IDUsed(ChID))
			{
				try
				{
					CurrentChapter = cProject.get_ChapterByID(ChID);
					DataToForm();
					FillSceneSummary();
					try
					{
						txtTitle.Focus();
						txtTitle.SelectAll();
					}
					catch (Exception ex)
					{
						ProjectData.SetProjectError(ex);
						Exception ex2 = ex;
						clsShared.cLog.AddAction(ex2, MethodBase.GetCurrentMethod());
						ProjectData.ClearProjectError();
					}
				}
				catch (Exception ex3)
				{
					ProjectData.SetProjectError(ex3);
					Exception ex4 = ex3;
					clsShared.cLog.AddAction(ex4, MethodBase.GetCurrentMethod());
					ProjectData.ClearProjectError();
				}
			}
		}

		private void DataToForm()
		{
			try
			{
				txtTitle.Text = CurrentChapter.Title;
				txtDesc.Text = CurrentChapter.DescText;
				chkSectionStart.Checked = CurrentChapter.SectionStart;
				FillCombos();
				Cancelled = false;
			}
			catch (Exception ex)
			{
				ProjectData.SetProjectError(ex);
				Exception ex2 = ex;
				clsShared.cLog.AddAction(ex2, MethodBase.GetCurrentMethod());
				ProjectData.ClearProjectError();
			}
		}

		private void FormToData()
		{
			try
			{
				CurrentChapter.Title = txtTitle.Text;
				CurrentChapter.DescText = txtDesc.Text;
				CurrentChapter.SectionStart = chkSectionStart.Checked;
				if (cmbBooks.SelectedIndex != -1)
				{
					CurrentChapter.BookID = ((clsBook)cmbBooks.SelectedItem).ID;
				}
				if (cmbParts.SelectedIndex != -1)
				{
					CurrentChapter.PartID = ((clsPart)cmbParts.SelectedItem).ID;
				}
			}
			catch (Exception ex)
			{
				ProjectData.SetProjectError(ex);
				Exception ex2 = ex;
				clsShared.cLog.AddAction(ex2, MethodBase.GetCurrentMethod());
				ProjectData.ClearProjectError();
			}
			CurrentChapter.Save();
		}

		private void cmdExit_Click(object eventSender, EventArgs eventArgs)
		{
			Cancelled = true;
			Hide();
		}

		private void cmdOK_Click(object eventSender, EventArgs eventArgs)
		{
			if (SaveOK())
			{
				Cancelled = false;
				Hide();
			}
		}

		private bool SaveOK()
		{
			bool result = default(bool);
			try
			{
				if (Operators.CompareString(Strings.Trim(txtTitle.Text), "", TextCompare: false) != 0)
				{
					FormToData();
					result = true;
					return result;
				}
				clsShared.cLang.TransMsgBox("You must specify a title");
				return result;
			}
			catch (Exception ex)
			{
				ProjectData.SetProjectError(ex);
				Exception ex2 = ex;
				clsShared.cLog.AddAction(ex2, MethodBase.GetCurrentMethod());
				ProjectData.ClearProjectError();
				return result;
			}
		}

		private void frmEditChapter_Load(object eventSender, EventArgs eventArgs)
		{
			try
			{
				if (Operators.CompareString(clsShared.cLang.CurrentLanguage, "English", TextCompare: false) != 0)
				{
					clsShared.cLang.TranslateForm(this);
				}
				clsShared.cFormFont.SetFormFont(this, clsShared.cSettings.sGet("FormFont", modVariables.DefaultUIFont.Name), clsShared.cSettings.sGet("UIFontSize", modVariables.DefaultUIFont.Size));
				TabControl1.TabPages.Remove(TabBooks);
			}
			catch (Exception ex)
			{
				ProjectData.SetProjectError(ex);
				Exception ex2 = ex;
				clsShared.cLog.AddAction(ex2, MethodBase.GetCurrentMethod());
				ProjectData.ClearProjectError();
			}
		}

		private void frmEditChapter_FormClosing(object eventSender, FormClosingEventArgs eventArgs)
		{
			if (eventArgs.CloseReason == CloseReason.UserClosing)
			{
				Cancelled = true;
			}
		}

		private void txtTitle_Enter(object eventSender, EventArgs eventArgs)
		{
			clsText cText = clsShared.cText;
			TextBox TextControl = txtTitle;
			cText.HighlightText(ref TextControl);
			txtTitle = TextControl;
		}

		private void FillSceneSummary()
		{
			int sceneCount = CurrentChapter.SceneCount;
			for (int i = 1; i <= sceneCount; i++)
			{
				txtSceneSummary.Text = txtSceneSummary.Text + "Scene: " + Conversions.ToString(i) + "\r\n";
				txtSceneSummary.Text += cProject.get_SceneByChID(CurrentChapter.ID, i).DescText;
				if (i < CurrentChapter.SceneCount)
				{
					txtSceneSummary.Text += "\r\n\r\n";
				}
			}
		}

		private void cmdSetupBooks_Click(object sender, EventArgs e)
		{
			new frmEditBooksParts(ref cProject).ShowDialog();
			FillCombos();
		}

		private void FillCombos()
		{
			SuppressComboChange = true;
			cmbBooks.Items.Clear();
			cmbParts.Items.Clear();
			cmbBooks.DisplayMember = "Title";
			IEnumerator enumerator = default(IEnumerator);
			try
			{
				enumerator = cProject.Books.GetEnumerator();
				while (enumerator.MoveNext())
				{
					clsBook item = (clsBook)enumerator.Current;
					cmbBooks.Items.Add(item);
				}
			}
			finally
			{
				if (enumerator is IDisposable)
				{
					(enumerator as IDisposable).Dispose();
				}
			}
			if (cmbBooks.Items.Count == 0)
			{
				cmbBooks.Enabled = false;
			}
			else
			{
				cmbBooks.Enabled = true;
				if (CurrentChapter.BookID > 0)
				{
					cmbBooks.SelectedIndex = cmbBooks.FindStringExact(cProject.get_BookByID(CurrentChapter.BookID).Title);
				}
				else
				{
					cmbBooks.SelectedIndex = 0;
				}
				FillPartsCombo();
			}
			SuppressComboChange = false;
		}

		private void FillPartsCombo()
		{
			cmbParts.Items.Clear();
			cmbParts.DisplayMember = "Title";
			clsBook clsBook = (clsBook)cmbBooks.SelectedItem;
			IEnumerator enumerator = default(IEnumerator);
			try
			{
				enumerator = cProject.Parts.GetEnumerator();
				while (enumerator.MoveNext())
				{
					clsPart clsPart = (clsPart)enumerator.Current;
					if (clsPart.BelongsToBookID == clsBook.ID)
					{
						cmbParts.Items.Add(clsPart);
					}
				}
			}
			finally
			{
				if (enumerator is IDisposable)
				{
					(enumerator as IDisposable).Dispose();
				}
			}
			if (cmbParts.Items.Count == 0)
			{
				cmbParts.Enabled = false;
				return;
			}
			cmbParts.Enabled = true;
			if (CurrentChapter.PartID > 0)
			{
				cmbParts.SelectedIndex = cmbParts.FindStringExact(cProject.get_PartByID(CurrentChapter.PartID).Title);
			}
			else
			{
				cmbParts.SelectedIndex = 0;
			}
		}

		private void cmbBooks_SelectedIndexChanged(object sender, EventArgs e)
		{
			if (!SuppressComboChange)
			{
				FillPartsCombo();
			}
		}

		private void cmdPrevChapter_Click(object sender, EventArgs e)
		{
			if (SaveOK())
			{
				Cancelled = false;
				Hide();
				PrevChapterEvent?.Invoke(CurrentChapter.ID);
			}
		}

		private void cmdNextChapter_Click(object sender, EventArgs e)
		{
			if (SaveOK())
			{
				Cancelled = false;
				Hide();
				NextChapterEvent?.Invoke(CurrentChapter.ID);
			}
		}
	}
}
